package cn.com.connext.scrm.repository.master;

import cn.com.connext.scrm.domain.master.Activity;
import cn.com.connext.scrm.domain.master.Coupon;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CouponRepository extends JpaRepository<Coupon, String>, JpaSpecificationExecutor {
    @Query(value = "select a.* from coupon a WHERE a.open_id is NULL  and a.period_validity > now() and state =0  ", nativeQuery = true)
    List<Coupon> getPostActivityForAnswers();

    Coupon findByProductIdAndId(@Param("productId") String productId, @Param("id") String id);

    List<Coupon> findByProductIdAndState(@Param("productId") String productId,@Param("state") Integer state);

    List<Coupon> findByCouponIdAndState(@Param("productId") String productId,@Param("state") Integer state);

    List<Coupon> findByCouponId(@Param("couponId") String couponId);
}
